<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('hostel_dropdown'))
{
	function hostel_dropdown($id = null, $selected = null, $prefix = null)
	{
		if (file_exists(BASEPATH . '/public/flatfiles/hostels.php'))
		{
			
			require (BASEPATH . '/public/flatfiles/hostels.php');
			
			$name = 'hostel_names';
			
			if ($prefix != null)
			{
				$name = $prefix . '[hostel_names]';
			}
			
			if ($id != null)
			{
				$sid = $name . "[$id]";
			} else
			{
				$sid = $name;	
			}
			
			
			
			$d = "<select name=\"$sid\" id=\"$sid\">\n";
			$d .= "\t<option value=\"0\">Please select...</option>";
			
			for ($i = 0; $i < count($hostel_array); $i++)
			{
				if ($selected == $hostel_array[$i]['id'])
				{
					$s = ' selected="selected"';
				} else
				{
					$s = '';	
				}
				
				$d .= "\t<option value=\"" . $hostel_array[$i]['id'] . "\"$s>" . $hostel_array[$i]['hostel_name'] . "</option>\n";
			}
			
		
			$d .= "</select>";
			return $d;
		}
	}
}

?>